package com.apes.fn.server.workDesk.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @program: apes-server
 * @description:
 * @author: czs
 * @create: 2023-06-12 17:29
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = VehicleControlItem.CONST_TABLE_NAME)
public class VehicleControlItem extends Model {
    public static final String CONST_TABLE_NAME = "vehicle_control_items";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车辆总控信息单据明细")
    @Comment("编号")
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "vehicle_control_id", referencedColumnName = "id")
    @Comment("主表编码")
    private VehicleControl vehicleControl;

    @NonNull
    @Column(name = "state", length = 32)
    private String state = "create";

    @NonNull
    @Column(name = "source_order", length = 20)
    @Comment("来源单号")
    private String sourceOrder; //来源

    @NonNull
    @Column(name = "source_order_type", length = 32)
    @Comment("来源单据类型")
    private String sourceOrderType;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "order_Create_Date")
    @Comment("来源单号创建日期")
    private Date orderCreateDate;

    @Column(name = "order_Create_Person", length = 20)
    @Comment("来源单号创建人")
    private String orderCreatePerson; //来源


}
